﻿<%@ Page Title="" Language="C#" MasterPageFile="~/UserCP.Master" AutoEventWireup="true" CodeBehind="ViewTicket.aspx.cs" Inherits="University.Workshop.WebApp.ViewTicket" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div style=' margin-bottom:20px;background-color: #4b6c9e; color: White;'>
        <h4 style='margin-top: 4px; font-size: large; color: White'>
           &nbsp;>Ticket information
        </h4>
    </div>
    <asp:MultiView runat="server" ID="MultiViewTicketInfo">
        <asp:View runat="server" ID="ShowTicketInfo">
            <div>
                <asp:ToolkitScriptManager runat="server" ID="scriptMan"/>
                <table>
                    <tbody>
                        <tr>
                            <td style='width: 120px; text-align: right;'>
                                <label>
                                    Title of the Issue:</label>
                            </td>
                            <td style='width: 425px; vertical-align: top'>
                                <h3 runat="server" id="IssueTitle" style='color: black; vertical-align: top; margin-top: 0px'>
                                    Nothing</h3>
                            </td>
                        </tr>
                        <tr>
                            <td style='width: 120px; text-align: right;'>
                                <label>Sent by:</label>
                            </td>
                            <td>
                                <asp:LinkButton runat="server" ID="LinkUser"></asp:LinkButton>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: right">
                                <label>
                                    Ticket date:</label>
                            </td>
                            <td>
                                <table>
                                    <tr>
                                        <td>
                                            <asp:Label runat="server" ID="LblTicketDate" ForeColor="Black"></asp:Label>
                                        </td>
                                        <td style="width: 40px;">
                                        </td>
                                        <td style='text-align: right;'>
                                            <asp:Label ID="Label1" runat="server" Text="Status:"></asp:Label>
                                        </td>
                                        <td style="vertical-align: top">
                                            
                                            <asp:Label runat="server" ID="LblStatus" ForeColor="Black"></asp:Label>
                                            <asp:UpdatePanel runat="server">
                                                <ContentTemplate>
                                                    <asp:DropDownList runat="server" ID="drpDwnEditStatus" AutoPostBack="True" 
                                                        onselectedindexchanged="drpDwnEditStatus_SelectedIndexChanged" 
                                                        Width="69px"/>
                                        </td>
                                        <td style="width: 40px;"><asp:Button runat="server" ID="btnConfirmClose" 
                                                Text="Confirm" Visible="False" onclick="btnConfirmClose_Click"/>
                                                <asp:ConfirmButtonExtender runat="server" ID="ConfirmClose" TargetControlID="btnConfirmClose"
                                            ConfirmText="The ticket will be marked as Closed, then no one will be able to reply. Confirm?" ConfirmOnFormSubmit="False" />
                                        </td>
                                            </ContentTemplate>
                                        </asp:UpdatePanel> 
                                        <td style='vertical-align: top; text-align: right;'>
                                            <label>
                                                Priority:</label>
                                        </td>
                                        <td  style='vertical-align: top;'>
                                            <asp:Label runat="server" ID="LblPriority" ForeColor="Black"></asp:Label>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td style='text-align: right;'>
                                <label>
                                    Related Purchase:</label>
                            </td>
                            <td style='background-color: #4b6c9e; height: 20px'>
                                <a runat="server" id="ProductName" style='color: White; font-family: Segoe UI; font-variant: small-caps;
                                    font-size: 15px; text-decoration: none;'>No Purchased
                                    <style>
                                        a:visited
                                        {
                                            text-decoration: none;
                                            color: White;
                                        }
                                        a:hover
                                        {
                                            text-decoration: underline;
                                            color: White;
                                        }
                                    </style>
                                </a>
                            </td>
                        </tr>
                        <tr><td style="height: 2px;vertical-align: top; text-align: right;"><label>
                                    Description:</label></td></tr>
                    </tbody>
                </table>
            </div>
            <div style="margin-left: 20px; margin-bottom: 10px;">
                <asp:TextBox ID="txtContent" TextMode="MultiLine" Height="170" Width="425" runat="server"
                                    ReadOnly="true"></asp:TextBox>
            </div>
            <asp:UpdatePanel runat="server" ID="updtPan">
                <ContentTemplate>
                    <div style="margin-top: 10px; margin-bottom: 5px;">
                        <h4 style='margin-top: 4px; background-color: #4b6c9e; font-size: large; color: White;
                            width: 320px; font-size: medium; -moz-border-radius: 5px; -webkit-border-radius: 5px;
                            border-radius: 5px;'>
                            &nbsp;>Replies
                        </h4>
                    </div>
                    <asp:MultiView runat="server" ID="MultiViewReplies">
                        <asp:View runat="server" ID="ShowReplies">
                            <div>
                        <asp:DataList runat="server" ID="dataListReplies" CellPadding="2" CellSpacing="2"
                            BorderStyle="Double" BorderColor="White" Width="100%" ItemStyle-BackColor="white"
                            ItemStyle-ForeColor="Black">
                            <ItemTemplate>
                                <table style="border: 1px #B9B9B9 solid; width: 500px">
                                    <tr>
                                        <td style="border: 1px #B9B9B9 solid; background-color: #4b6c9e; color: white">
                                            <asp:Label ID="lblDate" runat="server" Text='<%# Eval("Date") %>' />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="border: 1px #B9B9B9 solid; background-color: #B9B9B9;">
                                            <asp:LinkButton ID="lnkBtnUser" PostBackUrl='<%# GetLinkUser(Eval("UserId")) %>'
                                                runat="server" Text='<%# GetUser(Eval("UserId")) %>' />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="width: 500px;">
                                            <asp:Label ID="lblReply" runat="server" Text='<%# FormatReply(Eval("Reply")) %>' />
                                        </td>
                                    </tr>
                                </table>
                            </ItemTemplate>
                        </asp:DataList>
                    </div>
                        </asp:View>
                        <asp:View runat="server" ID="NoReplies">
                            <div>
                                <h4 style="font-size: medium">
                                    This ticket have no replies</h4>
                            </div>
                        </asp:View>
                    </asp:MultiView>  
                    <div style="margin-top: 10px; margin-bottom: 10px;">
                        <h4 style='margin-top: 4px; background-color: #4b6c9e; font-size: large; color: White;
                            width: 320px; font-size: medium; -moz-border-radius: 5px; -webkit-border-radius: 5px;
                            border-radius: 5px;'>
                            &nbsp;>Reply
                        </h4>
                    </div>
                    <asp:MultiView runat="server" ID="MultiViewReply">
                        <asp:View runat="server" ID="CanReply">
                            <div style="margin-bottom: 10px">
                                <asp:TextBox ID="txtReply" TextMode="MultiLine" Height="170" Width="425" runat="server"
                                    MaxLength="500" onKeyUp="Count(this,500)" onChange="Count(this,500)"></asp:TextBox>
                                <script type="text/javascript">
                                    function Count(text, long) {
                                        var maxlength = new Number(long);
                                        if (text.value.length > maxlength) {
                                            text.value = text.value.substring(0, maxlength);
                                            alert(" You can put only up to " + long + " chars");
                                        }
                                    }
                                </script>
                            </div>
                            <div>
                                <asp:Button runat="server" ID="btnSendReply" Text="Send Reply" OnClick="btnSendReply_Click" />
                            </div>
                        </asp:View>
                        <asp:View runat="server" ID="CanNotReply">
                            <div>
                                <h4 style="font-size: medium">
                                    This ticket is closed, so you can't reply</h4>
                            </div>
                        </asp:View>
                    </asp:MultiView>
                </ContentTemplate>
            </asp:UpdatePanel>
        </asp:View>
        <asp:View runat="server" ID="DontShowTicketInfo">
            <div>
                <h4 style="font-size: medium">This ticket not belongs to you or you don't have sufficient privileges to see it</h4>
            </div>
        </asp:View>
    </asp:MultiView>
</asp:Content>
